<template>
	<view>
		
		<view class="list-common" @click="nextPage('../bangdingtongzhishouji/index')">
			绑定通知手机号
		</view>
		<view class="list-common" @click="nextPage('../changephone/index')">
			修改手机号
		</view>
		<view class="list-common" @click="nextPage('../setdenglupwd/index')">
			修改登录密码
		</view>
		<view class="list-common" @click="nextPage('../setzijinmima/index')">
			重置支付密码
		</view>
		<view class="list-common" @click="nextPage('../setyinhangka/index')">
			团购收款信息(银行卡)
		</view>
		
		<view class="list-common" @click="nextPage('../setzhifubao/index')">
			团购收款信息(支付宝)
		</view>
		<view class="list-common" @click="nextPage('../setweixinnew/index')">
			团购收款信息(微信)
		</view>
		<view class="list-common" @click="nextPage('../setweixin/index')">
			提现收款信息(微信)
		</view>
		<view class="list-common" @click="gengxin">
			版本号：{{version}}
		</view>
		<view class="log-out" @click="logout">
			退出登录
		</view>
		
		<view class="bottom-desc">
			<view>华预南阳中央厨房有限公司</view>
			<view>
				Copyright @ 2022-2023 All Rights Reserved
			</view>
		</view>
	</view>
</template>

<script>
	let globalData={}
	export default {
		data() {
			return {
				version:''
			}
		},
		onLoad() {
			this.version=this.VERSION
			
			switch(uni.getSystemInfoSync().platform){
			    case 'android':
			
			      this.platform= 'android'
					
			       break;
			
			    case 'ios':
			        this.platform= 'ios'
			
			       break;
			
			    default:
			
			        this.platform= 'other'
			
			       break;
				  
			
			}
			
		},
		onShow(){
			
		},
		methods: {
			doUpData(url) {
				
			  uni.showToast({
			      title: '更新完成将自动安装',
			      duration:4000,
			  	icon:'none'
			  });
			    uni.downloadFile({//执行下载
			        url: url, //下载地址
			        success: downloadResult => {//下载成功
			          
			            if (downloadResult.statusCode == 200) {
			               plus.runtime.install(//安装
			                   downloadResult.tempFilePath, {
			                       force: true
			                   },
			                   function(res) {
			               		uni.showToast({
			               		    title: '更新成功，即将重启',
			               		    duration:4000,
			               			icon:'none'
			               		});
			                       setTimeout(function(){
									   plus.runtime.restart();
								   },4000)
			                       
			                   }
			               );
			            }
			        },
					fail:()=>console.log('下载失败')
			    });
			},
			gengxin(){
				
				
				
				// uni.share({
				// 	provider: "weixin",
				// 	scene: "WXSceneSession",
				// 	type: 1,
				// 	summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
				// 	success: function (res) {
				// 		console.log("success:" + JSON.stringify(res));
				// 	},
				// 	fail: function (err) {
				// 		console.log("fail:" + JSON.stringify(err));
				// 	}
				// });
				
				
				
				if(this.platform!='android'){
					return
				}
				let that=this
				that.apiget('/api/home/update').then(res => {
					if(res.Code==10200){
						let data=res.Data
						
						that.android_url_=res.Data.android_url_
						if(data.android_version!=that.version&&that.platform=='android'){
							that.doUpData(res.Data.android_url_)
						}else{
							uni.showToast({
							    title: '已是最新版',
							    duration:4000,
								icon:'none'
							});
						}
						
						
						
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			userUser_info(){
				uni.showLoading({
				    title: ''
				});
				let that=this
				let obj={
					
					mobile: globalData.userInfo.mobile,
					uid: globalData.userInfo.uid
				}
				this.$api.userUser_info(obj).then(res => {
				   if(res.Code==200){
					
					that.showData=res.Data
					 
				   }
				   uni.hideLoading();
				}).catch(err => {
					uni.hideLoading();
				　　
				})
			},
			logout(){
				let that=this
				uni.showModal({
				    title: '提示',
				    content: '确认退出？',
				    success: function (res) {
				        if (res.confirm) {
							uni.clearStorage();
							uni.reLaunch({
							    url: '/pages/login/index'
							});
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
				
			},
			nextPage(path){
				
				uni.navigateTo({
				    url: path
				});
			}
		}
	}
</script>

<style>
	.log-out{
		display:flex;
		height:100rpx;
		background:#f9436b;
		width:690rpx;
		justify-content: center;
		align-items: center;
		
		color:#fff;
		margin:44rpx auto;
		border-radius:20rpx;
	}
	page{
		height:100%;
		
		background:#f8f8f8;
	}
	.bottom-desc{
		position:fixed;
		bottom:30rpx;
		width:100%;
		text-align: center;
	}
	.list-common{
		background:#fff;
		padding:0 60rpx;
		height:110rpx;
		display:flex;
		align-items: center;
		color:#333;
		box-sizing: border-box;
		/* background:url(../../static/indexnext.png) #fff no-repeat 95% center; */
		background-size:10rpx auto;
		border-bottom:1rpx solid #edebec;
	}
</style>

